#ifndef EBNETWORK_H
#define EBNETWORK_H

#include <QObject>
#include <QThread>
#include <QTimer>

#define URL_FIRM_LOGIN      "api.needleos.com"
#define URL_FIRM_GRPC       "grpc.needleos.com"
#define URL_BAIDU           "www.baidu.com"

class EBNetwork : public QObject
{
    Q_OBJECT
public:
    EBNetwork(QObject *parent = nullptr);
    ~EBNetwork();
    
    static EBNetwork* Get();
    bool checkNet();
private:
    QThread* m_thd;
    QTimer* m_refreshNet;
    
    bool m_quitCheck{false};
    bool m_netStatus{false};   //false:not network
    bool m_isStartPing{false};
public slots:
    void on_quit();
private slots:
    void init();
    void checkNetworkLoop();
    void existOneHaveNet();
    bool PingTest(const QString&);
    bool GetGateWay(QString& ip);
    void setNetStatus(bool netStatus);
    bool netStatus() const;
signals:    
    void netStatusChanged();
    
};

#endif // EBNETWORK_H
/*
 * 检查网络类；网络变化时候发送信号;
 * 懒汉单例
**/
